import Redis from 'ioredis';

class RedisSingleton {
  private static instance: RedisSingleton;
  private redis: Redis;

  private constructor() {
    this.redis = new Redis({
      host: 'redis-cnlfbr3k6i11vte5a.redis.volces.com', // Replace with your Redis server host
      port: 6379, // Replace with your Redis server port
      password: 'qwer@123123', // Replace with your Redis server password (if any)
      username: 'lovetalkon', // Replace with your Redis server username
    });
  }

  public static getInstance(): RedisSingleton {
    if (!RedisSingleton.instance) {
      RedisSingleton.instance = new RedisSingleton();
    }
    return RedisSingleton.instance;
  }

  public getRedis(): Redis {
    return this.redis;
  }
}

export default RedisSingleton.getInstance().getRedis();